<!doctype html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta content="always" name="referrer">
    <#include "../common/header.html">

</head>
<body>
<!--最外面的灰底框,用于与ifram区别开-->
<div class="col-xs-12 lightgray_div" >
    <!--白底框-->
    <div class="col-xs-12 white_div">
        <!--返回按钮-->
        <div class="row all_input_div" style="">
            <div class="col-xs-6">
                <input type="hidden" name="id" id="id" value="${member_id!?html}"/>
                <form class="form-horizontal"  role="form" id="form1">
                    <input type="hidden" name="name" value="${name!?html}">
                    <input type="hidden" name="account" value="${card_number!?html}">
                    <div class="form-group">
                        <label class="col-xs-3 control-label">用户名称</label>
                        <div class="col-xs-9">
                            <input type="text" class="form-control input_400px" disabled id="name"  value="${name!?html}"
                                   placeholder="会员名称">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-xs-3 control-label">账号</label>
                        <div class="col-xs-9">
                            <input type="text" class="form-control input_400px" disabled id="card_number"  value="${card_number!?html}"
                                   placeholder="会员卡号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label"><em class="text-red">*</em>密码</label>
                        <div class="col-xs-9">
                            <input type="hidden" name="is_update_password" id="is_update_password" value="0" >
                            <input type="hidden" name="password" id="password" >
                            <input type="text" class="form-control input_400px"  id="show_password"
                                   placeholder="请输入密码">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-3 control-label">所属角色</label>
                        <div class="col-xs-9">
                            <select class="form-control input_400px"  name ="role_ids" id="role_ids" multiple="multiple" autofocus  >
                            </select>
                        </div>
                    </div>

                </form>
                <div class="form-group ">
                    <label class="col-xs-3 control-label"></label>
                    <a class="gbn gbn-m" href="javascript:" id="btn_save" onclick="E.save();">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
<#include "../common/layui_init.html">
<script type="text/javascript">

    var E = {
        save: function () {
            var show_password=$("#show_password").val()
            if(!tool.isEmpty(show_password)){
                $("#is_update_password").val("1")
                $("#password").val($.md5(show_password));
            }
            $.post("/admin/user/add_or_edit", $("#form1").serialize(), function (o) {
                if (o.code == 0) {
                    $.post("${request.contextPath}/jsf_member/setMemberUserId", {id:"${member_id!?html}",user_id:o.data}, function (o) {
                        if (o.code == 0) {
                           layui_layer.layer_close_current();
                        } else {
                            layui_layer.error_alert(o.message);
                        }
                    })
                } else {
                    layui_layer.error_alert(o.message);
                }
            })
        },
        load: function () {
            $.getJSON("${request.contextPath}/jsf_member/getById", {id: $("#id").val()}, function (o) {
                if (o.code == 0) {
                    $("#form1").setFormValues(o.data);
                }
            });
        }

    }
    $(function () {
        //回车点击事件 保存
        enter_event.event_save_click();
        $.ajaxSettings.async=false;
        select2_utils.load_select2("sex_id","请选择性别","/admin/dict/getUsableDictByType/SEX",{})
        select2_utils.load_select2("role_ids","请选择所属角色","/admin/role/getAll",{})
        var id = $("#id").val()
        console.log(document.body.clientWidth);
        console.log(document.body.clientHeight);
        if (id != null && id != "") {
            E.load();
        }

    });
</script>
<#include "../common/footer-inner.html">
</html>
